<?php  include VIEWPATH.'common/head.php';  ?>
    <script type="text/javascript">
        var status = '<?php echo $_GET['status'];?>';
        if(status == '-1'){
            alert('fail:<?php echo $_GET['msg'];?>');
        }
        function del_up_img(img_id){
            if(confirm("确定删除吗？")){
                $.ajax({
                    type:'get',
                    url:'index.php?c=imgLib&m=del_up_img&id='+img_id,
                    data:{},
                    cache:false,
                    dataType:'json',
                    success:function(data){
                        if(data.errorCode == 0) {
                            //表单提交
                            window.location.href = window.location.href;
                            return;
                        }else{
                            console.log(data.errorMsg);
                            alert(data.errorMsg);
                        }
                    },
                    error:function(data){
                        console.log(data);
                        alert(data);
                    }
                });
            }
        }
    </script>
    <body class="gray-bg">
    <div class="wrapper wrapper-content ">
        <div class="add-btn" style="float:right;margin-bottom:5px;">
            <div class="modal fade" id="add_img" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" style="display: none;">
                <div class="modal-dialog" style="width: 60%;"><div class="modal-content"></div></div>
            </div>
        </div>
        <div class="clearfix"></div>

        <div class="row">
            <div class="col-sm-12">
                <div class="ibox float-e-margins">
                    <div class="ibox-title">
                        <a class="btn btn-danger" href="index.php?c=imgLib&m=add_img" data-toggle="modal" data-target="#add_img">添加图片</a>
                        <div class="ibox-tools">
                            <a class="collapse-link">
                                <i class="fa fa-chevron-up"></i>
                            </a>
                            <a class="close-link">
                                <i class="fa fa-times"></i>
                            </a>
                        </div>
                    </div>
                    <div class="ibox-content">

                        <form class="form-horizontal" id="f_form" action="index.php?c=<?php echo $_REQUEST['c'];?>&m=<?php echo $_REQUEST['m'];?>" name="form" method="post">
                            <div class="form-group">
                                <div class="text-right col-sm-2">
                                    <label class="control-label">图片目录：</label>
                                </div>
                                <div class="col-sm-2">
                                    <select name="directory" class="form-control">
                                        <option value="">全部</option>
                                        <?php $directory = $this->ImgLibModel->directory;
                                        foreach($directory as $k => $d){ ?>
                                            <option value="<?php echo $k;?>"  <?php echo $k == $_REQUEST["directory"] ? 'selected' : '';?>><?php echo $d;?></option>
                                        <?php } ?>
                                    </select>
                                </div>
                                <div class="text-right col-sm-2">
                                    <label class="control-label">查看自己：</label>
                                </div>
                                <div class="col-sm-2">
                                    <select name="is_me" class="form-control">
                                        <option value="">全部</option>
                                        <option value="1" <?php echo $_REQUEST['is_me']==1 ? 'selected' : '';?>>是</option>
                                    </select>
                                </div>
                                <div class="col-sm-1">
                                    <button class="btn btn-sm btn-primary" type="submit"> 搜索 </button>
                                </div>
                            </div>
                        </form>
                        <div class="post_list">
                            <div class="table-data-list">
                                <form name="form" class="form" action="index.php?c=<?php echo $_REQUEST['c']; ?>&m=<?php echo $_REQUEST['m'];?>" method="post">
                                    <table class="table">
                                        <thead>
                                            <tr class="active">
                                                <th><input type="checkbox" name="chkall" onclick="checkAll('prefix', this.form, 'id')" class="checkbox"></th>
                                                <th>图片</th>
                                                <th>目录</th>
                                                <th>图片地址</th>
                                                <th>宽高</th>
                                                <th>上传时间</th>
                                                <th></th>
                                            </tr>
                                        </thead>
                                        <tbody>
                                        <?php foreach($imgList as $img){
                                            $category = $img["category"];
                                            ?>
                                            <tr>
                                                <td><input type="checkbox" class="checkbox" name="id[]" value="<?php echo $img['id'];?>"/></td>
                                                <td>
                                                    <?php if($category){ ?>
                                                        <img src="<?php echo IMG_URL.$img["path"];?>" width="160px" height="90px">
                                                    <?php }else{ ?>
                                                        <img src="<?php echo IMG_URL.$img["path"];?>" width="100px" height="100px">
                                                    <?php } ?>
                                                </td>
                                                <td><?php echo $directory[$img["directory"]];?></td>
                                                <td><?php echo  $img["path"];?></td>
                                                <td><?php echo "宽:".$img["w"]."; 高:".$img["h"];?></td>
                                                <td><?php echo date("Y-m-d H:i:s", $img["dateline"]);?></td>
                                                <td>
                                                    <a href="javascript:void(0)" onclick="del_up_img(<?php echo $img['id'];?>)">删除</a>
                                                </td>
                                            </tr>
                                        <?php } ?>
                                        </tbody>
                                    </table>
                                </form>
                            </div>
                            <div class="set_page">
                                <?php echo $multipage; ?>
                                <div class="clearfix"></div>
                            </div>

                        </div>

                    </div>
                </div>
            </div>

        </div>


    </div>
    <script src="http://gosspublic.alicdn.com/aliyun-oss-sdk-4.4.4.min.js"></script>
<?php  include VIEWPATH.'common/footer.php';  ?>